package br.usp.wta.aux;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import br.usp.language.morph.AnalisadorMorfologico;
import br.usp.language.morph.MorphologicAnalyser;
import br.usp.language.morph.TokenMorph;

public class TextMorphs {
    
    private static final String DICFILE = "resources/port";
    private static final String LISTFILE = "resources/port_amor_config.list";
    private static final String NEWSIN = "resources/training/news_in.txt";
    private static final String NEWSTEMP = "resources/training/news_temp.txt";
    private static final String PONCT = " (.*?)([;,.])";
    
    public static void main(String[] args) throws IOException {
        
        //MorphologicAnalyser ma = new PortugueseAnalyser(DICFILE, LISTFILE);
        MorphologicAnalyser ma = new AnalisadorMorfologico(DICFILE);

        File out = new File(NEWSIN);
        Reader reader = new FileReader(out);        
        ma.setInput(reader);
        
        List<TokenMorph> tokens = new ArrayList<TokenMorph>();
        while (ma.hasMoreTokens()) {
            TokenMorph[] tks = ma.getNextTokens();
            if ((tks != null) && (tks.length > 0)) {
                tokens.add(tks[0]);
            }
            else
                tokens.add(new TokenMorph("___", "___", "___", null, true));
        }
        
        for (TokenMorph tk: tokens)
            System.out.print(tk.getLexeme() + "(" + tk.getType() + ") ");
        System.out.println("");
        
        reader.close();
    }

}
